<?php
namespace app\admin\validate;

use think\Validate;

/**
* 
*/
class Icon extends Validate
{
   protected $rule = [
        'zh_name'       => 'require',
        'eb_name'       => 'is:chsDash',
        'price'       => 'require',
        'image_url_1'       => 'require',
        'label_standard_id'       => 'require',
        'label_applicable_area_id'       => 'require',
        'label_type_id'       => 'require',
        'label_content_id'       => 'require',
        'label_applicable_scene_id'       => 'require',
        'label_material_id'       => 'require',
        'label_size_id'       => 'require',
        'delivery_time'       => 'require',
    ];
    
    protected $message = [
        'zh_name.require'       => '请填写中文名',
        'eb_name.require'       => '请填写英文名',
        'price.require'       => '请填写价格',
        'image_url_1.require'       => '请上传图片',
        'label_standard_id.require'       => '请选择标识尺寸',
        'label_applicable_area_id.require'       => '请选择标识适用地区',
        'label_type_id.require'       => '请选择标识类别',
        'label_content_id.require'       => '请选择标识样式',
        'label_applicable_scene_id.require'       => '请选择标识应用场景',
        'label_material_id.require'       => '请选择标识材质',
        'label_size_id.require'       => '请选择标识尺寸',
        'delivery_time.require'       => '请选择标识日期'
    ];
    protected $scene = [
        //编辑场景
        'edit'  => [
        	'zh_name'       => 'require',
	        'eb_name.require'       => 'require',
	        'price.require'       => 'require',
	        'label_standard_id'       => 'require',
	        'label_applicable_area_id'       => 'require',
	        'label_type_id'       => 'require',
	        'label_content_id'       => 'require',
	        'label_applicable_scene_id'       => 'require',
	        'label_material_id'       => 'require',
	        'label_size_id'       => 'require',
	        'delivery_time'       => 'require'
        ],
    ];

	/**
	*自定义验证 
	* 手机号格式检查
	* @param string $mobile
	* @return bool
	*/
	protected function check_mobile_number($mobile)
	{
	    if (!is_numeric($mobile)) {
	        return false;
	    }
	    $reg = '#^13[\d]{9}$|^14[5,7]{1}\d{8}$|^15[^4]{1}\d{8}$|^17[0,6,7,8]{1}\d{8}$|^18[\d]{9}$#';

	    return preg_match($reg, $mobile) ? true : false;
	}


}